package com.stone.front.dish.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.stone.back.dish.entity.BfCombo;
import com.stone.back.dish.entity.BfComboDish;
import com.stone.back.dish.entity.BfDish;
import com.stone.back.dish.entity.BfWeekmenu;
import com.stone.back.dish.entity.BfWeekmenuCombo;
import com.stone.base.dao.BaseDao;

/**
 * 商品管理
 * @author Stone P
 *
 */
@Repository
public class WaresFrontDao extends BaseDao implements IWaresFrontDao {
	/**
	 * 获取本周菜单
	 * @param date		当天所在周的第一天日期
	 * @return
	 */
	@Override
	public List<BfWeekmenu> selectWeekMenu(String date) {
		String hql = "from BfWeekmenu where sellweek = '" + date + "'";
		List<BfWeekmenu> list = this.hibernateTemplate.find(hql);
		return list;
	}
	
	/**
	 * 获取本周套餐列表
	 * @param date		当天所在周的第一天日期
	 * @return
	 */
	@Override
	public List<BfWeekmenuCombo> selectWeekCombo(String date) {
		String hql = "from BfWeekmenuCombo where selldate <= 5 and weekMenu.sellweek = '" + date + "' order by selldate asc";
		List<BfWeekmenuCombo> list = this.hibernateTemplate.find(hql);
		return list;
	}

	/**
	 * 获取当天套餐信息
	 * @param date		当天所在周的第一天日期
	 * @param sellDate	当天是本周第几天
	 * @return
	 */
	@Override
	public List<BfWeekmenuCombo> selectTodayCombo(String date, int sellDate) {
		String hql = "from BfWeekmenuCombo where weekMenu.sellweek = '" + date + "' and selldate = ?";
		List<BfWeekmenuCombo> list = this.hibernateTemplate.find(hql, sellDate);
		return list;
	}

	/**
	 * 获取套餐菜品信息
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public List<BfComboDish> selectComboDish(int comboId) {
		String hql = "from BfComboDish where comboid = ?";
		List<BfComboDish> list = this.hibernateTemplate.find(hql, comboId);
		return list;
	}

	/**
	 * 查询套餐和菜品关系详情
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public List<BfComboDish> selectComboDishDetail(int comboId) {
		List<BfComboDish> comboDishList = this.hibernateTemplate.find("from BfComboDish where comboid = ? order by dishid desc", comboId);
		return comboDishList;
	}

	/**
	 * 根据类型查询商品信息
	 * @param typeId	类型Id
	 * @return
	 */
	@Override
	public List<BfDish> selectDishByType(int typeId) {
		List<BfDish> dishList = this.hibernateTemplate.find("from BfDish where status = 1 and dishtypeid = ? order by dishid desc", typeId);
		return dishList;
	}

	/**
	 * 查询套餐信息
	 * @return
	 */
	@Override
	public List<BfCombo> selectCombo() {
		List<BfCombo> comboList = this.hibernateTemplate.find("from BfCombo where status = 1 order by comboid desc");
		return comboList;
	}
	
	/**
	 * 查询商品详情
	 * @param dishId	商品Id
	 * @return
	 */
	@Override
	public BfDish selectDishById(int dishId) {
		BfDish dish = this.hibernateTemplate.get(BfDish.class, dishId);
		return dish;
	}
	
	/**
	 * 查询套餐详情
	 * @param comboId	套餐Id
	 * @return
	 */
	@Override
	public BfCombo selectComboById(int comboId) {
		BfCombo combo = this.hibernateTemplate.get(BfCombo.class, comboId);
		return combo;
		
	}
}
